// pages/youhuicars/youhuicars.js
const app = getApp()
Page({
  data: {
    currentData: 0,
    list:''

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getlist(1)
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  bindchange: function (e) {  //切换头部
    const that = this;
    that.setData({
      currentData: e.detail.current
    })
  },
  //点击切换，滑块index赋值
  checkCurrent: function (e) {
    const that = this;
    if (that.data.currentData === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentData: e.target.dataset.current
      })
      let status = Number(this.data.currentData)+1
      that.getlist(status)
    }
  },
  getlist(status){ //获取优惠券
    let _that = this;
    wx.request({   //传后台
      url: app.globalData.url + '/jxb/oneself/getUserVocher',
      method: 'POST',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      data: {
        token: wx.getStorageSync('token'),
        uid: wx.getStorageSync('uid'),
        status: status,
      },
      success: function (res) {
      console.log(res.data)
        _that.setData({
        list:res.data.data
      })
      },

    })
  }
})